package com.seuic.hnapps.util;

import com.solab.iso8583.IsoMessage;
import com.solab.iso8583.IsoType;

/**
 * 利率查询
 */
public class LLInstall {
    public IsoMessage packRequest(String transn) {
        IsoMessage msg = new IsoMessage();
        String encflag = Constants.YANTAI_ENCFLG2;
        msg.setType(0x0200);
        msg.setHeadValue(1, String.valueOf(Constants.ATMP_HEADER_LENGTH), IsoType.BCD, 2);
        msg.setHeadValue(2, Constants.YANTAI_PACKVS, IsoType.ALPHA, 2);
        msg.setHeadValue(3, Constants.YANTAI_TERMVS, IsoType.ALPHA, 8);
        msg.setHeadValue(4, encflag, IsoType.ALPHA, 1); // 加密标志：业务交易，公网传输1-报文加密，专线传输2-磁道加密
        msg.setHeadValue(5, Constants.YANTAI_BANKID, IsoType.ALPHA, 8);
        msg.setHeadValue(6, Constants.YANTAI_TERMNO, IsoType.ALPHA, 8);
        msg.setHeadValue(7, "0000", IsoType.ALPHA, 4); // 8583域部分长度，组包时动态填充

        msg.setValue(3, "570000", IsoType.ALPHA, 6);
        msg.setValue(7, DateUtil.getCurrentTime(DateUtil.M_TIME_PATTERN), IsoType.ALPHA, 10);
        msg.setValue(8, Constants.YANTAI_CHANLENO, IsoType.ALPHA, 2);
        msg.setValue(11, transn, IsoType.ALPHA, 6);
        msg.setValue(20, "00000000", IsoType.ALPHA, 8);
        msg.setValue(22, "021", IsoType.ALPHA, 3);
        msg.setValue(41, Constants.YANTAI_TERMNO, IsoType.ALPHA, 8);
//        // 第49域，币种
//        msg.setValue(49, "156", IsoType.ALPHA, 3);
        if (Constants.isSM) {
            msg.setValue(53, Constants.DEMO_F53, IsoType.ALPHA, 16);
        }
        msg.setValue(57, Constants.YANTAI_F57, IsoType.LLLVAR, 127);
        // 第60域，按实际填写
        msg.setValue(60, Constants.YANTAI_BATCHNO + "6" + "0", IsoType.LLVAR, 30);
        msg.setValue(128, "00000000", IsoType.ALPHA, 8);
        return msg;
    }
}
